<?php

if(isset($_POST['submitPRO']))
    {
		
  
     if(!isset($_SESSION))
session_start();

   if(isset($_SESSION['login']))
{  

    if((isset($_FILES['image'])) and ($_FILES['image']['name']!='')){
        $img="image";
      
    }
    else {
        $img=false;
       
    }
     $size=$_POST['size']; 
     $price=$_POST['price'];
     $quantity=$_POST['quantity'];
     $category=$_POST['category'];
     $st_ID=$_SESSION['store_id'];///fixed 3shan hna5do mn alsession b3d kda 
     $ProductDescrpition="";
     include 'productClass.php';
     
         $pro=new Product($st_ID,$category,$size,$img,$price,$quantity ,$ProductDescrpition);
          $pro->getProducts();
     header("location:showProducts.php?action=showProducts&Sid=$st_ID");
     
} else
{
    header("Location:login.php");
}  
     
    
}
else if(isset($_POST['savePRO']))
    {
		
  
     if(!isset($_SESSION))
session_start();

   if(isset($_SESSION['login']))
{  

    if((isset($_FILES['image'])) and ($_FILES['image']['name']!='')){
        $img="image";
      
    }
    else {
        $img=false;
       
    }
     $size=$_POST['size']; 
     $price=$_POST['price'];
     $quantity=$_POST['quantity'];
     $category=$_POST['category'];
     $ProductDescrpition="";
     $proID=$_POST['proID'];
     include 'productClass.php';
     $pro=new Product();
         $pro->UpdateProduct($proID, $category, $size, $img, $price, $quantity, $ProductDescrpition);
     header("location:showProducts.php?action=showProductInfo&Pid=$proID");
     
} else
{
    header("Location:login.php");
}  
     
    
}    

else if($_GET['action'] and $_GET['action']=="add"){

    if(!isset($_SESSION))
     {
         session_start();
         
     }
   if(isset($_SESSION['login']))
{   
    include './addProductForm.php';
}   else
{
    header("Location:login.php");
}
}




    
?>
